// TOWN SCRIPT
//    Town 2: Basement

// This is the special encounter script for this town.
// The states INIT_STATE, EXIT_STATE, and START_STATE have
// meanings that are described in the documentation. States you write
// yourself should be numbered from 10-100.

// flags:
// 2, 4 = door unlocked to wine storage.
//

begintownscript;

variables;

short choice;

body;

beginstate INIT_STATE;
	turn_off_training(TRUE);
	set_crime_tolerance(5);
break;

beginstate EXIT_STATE;
break;

beginstate START_STATE;
break;

beginstate 10;
	block_entry(TRUE);
	move_to_new_town(1, 27, 52);
break;

beginstate 11;
	if (get_flag(2, 0) == 0) {
		set_flag(2, 0, 1);
		message_dialog("You feel a cool breeze flowing down the corridor from a vent at the end of the hall.", "You dimly see a fan lazily turning in the opening.");
	}
break;

beginstate 12;
	if (get_flag(2, 1) == 0) {
		reset_dialog();
		add_dialog_str(0, "The fan doesn't seem to be working, just lazily spinning with the outside breeze.", 0);
		if (has_item(456)) {
			add_dialog_str(1, "It's possible that you might be able to get the fan using your screwdriver.", 0);
			add_dialog_str(2, "Remove the fan?", 0);
			add_dialog_choice(0, "No");
			add_dialog_choice(1, "Yes");
		}
		else {
			add_dialog_str(1, "It looks as if you can remove the fan, if you had a tool or two to help you.", 0);
			add_dialog_choice(0, "Ok");
		}
		choice = run_dialog(1);
		if (choice == 2) {
			// should only happen with yes/no dialog...
			set_flag(2, 1, 1);
			message_dialog("You carefully remove the fan from it's spindle.", "");
			reward_give(455);
			award_party_xp(200, 25);
		}
	}
break;

beginstate 13;
	if (get_flag(2, 2) == 0) {
		set_flag(2, 2, 1);
		message_dialog("The basement is clammy and dark.", "A slight breeze is flowing from the north.");
	}
break;

beginstate 14;
	if (get_flag(2, 3) == 0) {
		set_flag(2, 3, 1);
		message_dialog("The manor's wine cellar is well stocked with bottles of wine and spirits from all over.", "This place seems remarkably clean compared to the rest of the basement.  Seems this is where the caretaker spends a great deal of time.");
	}
break;

beginstate 15;
	if ((get_flag(50, 4) > 0) && (get_flag(50, 10) == 0)) {
		set_flag(50, 10, 1);
		message_dialog("In a small indention inside the quern, you find another journal.", "");
		reward_give(459);
		award_party_xp(100, 25);
	}
	else {
		message_dialog("The quern is empty and dry.", "Nothing else seems to be in it.");
	}
break;
